package codeRandomThoughts.Test459重复的子字符串;

import java.util.Arrays;

public class Solution {
    public boolean repeatedSubstringPattern(String s) {
        String a = s + s;
        char[] chars = a.toCharArray();
        char[] chars1 = Arrays.copyOfRange(chars, 1, chars.length - 1);
        String s1 = new String(chars1);
        int i = s1.indexOf(s);
        if (i == -1)
            return false;
        return true;
    }

    /**
     * 一行搞定!其实就是上面的简化版本
     * @param s
     * @return
     */
    public boolean repeatedSubstringPattern2(String s) {
        return (s + s).substring(1, s.length() * 2 - 1).contains(s);
    }
}
